//@author A0080442N
#include "Task.h"

Task::Task() {
}

Task::Task(string activity, string venue, TaskItTime timeStart, TaskItTime timeEnd, string category, Date date) {
	_activity = activity;
	_venue = venue;
	_timeStart = timeStart;
	_timeEnd = timeEnd;
	_category = category;
	_date = date;
	_isDone = false;

	if (_date.getDisplay() == EMPTY_FIELD) {
		_isFloating = true;
	} else {
		_isFloating = false;
	}
}

void Task::editTask(string activity, string venue, TaskItTime timeStart, TaskItTime timeEnd, string category, Date date) {
	_activity = activity;
	_venue = venue;
	_timeStart = timeStart;
	_timeEnd = timeEnd;
	_category = category;
	_date = date;

	if (_date.getDisplay() == EMPTY_FIELD) {
		_isFloating = true;
	} else {
		_isFloating = false;
	}
	return;
}

string Task::getAllDetails() {
	ostringstream taskDetails;
	taskDetails << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << DISPLAY_ACTIVITY << getActivity() << NEW_LINE;
	taskDetails << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE <<DISPLAY_VENUE << getVenue() << NEW_LINE;
	taskDetails << DISPLAY_TIME_START << getTimeStart().getDisplay() << NEW_LINE;
	taskDetails << WHITE_SPACE << DISPLAY_TIME_END << getTimeEnd().getDisplay() << NEW_LINE;
	taskDetails << WHITE_SPACE << WHITE_SPACE << DISPLAY_CATEGORY << getCategory() << NEW_LINE;
	taskDetails << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE 
				<< WHITE_SPACE << WHITE_SPACE << WHITE_SPACE <<DISPLAY_DATE << getDate().getDisplay() << NEW_LINE;
	if (getDone()) {
		taskDetails << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << DISPLAY_STATUS <<  DISPLAY_DONE << NEW_LINE;
	} else {
		taskDetails << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << WHITE_SPACE << DISPLAY_STATUS <<  DISPLAY_NOT_DONE << NEW_LINE;
	}
	return taskDetails.str();
}

bool Task::isSameTask(Task secondTask) {
	return (secondTask.getActivity() == getActivity() &&
			secondTask.getVenue() == getVenue() &&
			secondTask.getTimeStart().getDisplay() == getTimeStart().getDisplay() &&
			secondTask.getTimeEnd().getDisplay() == getTimeEnd().getDisplay() &&
			secondTask.getDate().getDisplay() == getDate().getDisplay() &&
			secondTask.getCategory() == getCategory() &&
			secondTask.getDone() == getDone());
}

void Task::markDone() {
	_isDone = true;
}

void Task::markUndone() {
	_isDone = false;
}

void Task::confirm() {
	_activity = _activity.substr(SLOT_SEVEN);
}

string Task::getActivity() {
	return _activity;
}

string Task::getVenue() {
	return _venue;
}

TaskItTime Task::getTimeStart() {
	return _timeStart;
}

TaskItTime Task::getTimeEnd() {
	return _timeEnd;
}

string Task::getCategory() {
	return _category;
}

Date Task::getDate() {
	return _date;
}

bool Task::getDone() {
	return _isDone;
}

bool Task::getFloating() {
	return _isFloating;
}